

class Animal():

    def __init__(self,weight,num1):
        self.weight = weight
        self.num1 = num1

    def eat(self):
        print(f'我体重{self.weight},每天吃{self.num1}顿饭')

    def sleep(self):
        print('睡觉')

    def game(self):
        print ('打游戏')

# a = Animal(110,3)
# a.eat()

# 子类里面没有，就会去父类里面找,子类里面有的，就用子类的
# 子类已经有了，但是还想用父类的功能，我们通过super继承一下
# 父类的方法不能够满足我们的使用的时候，但是父类的方法还是需要使用的，我们通过继承的方式，把父类的能力继承下来，在定制化的开发
class Person(Animal):

    # Animal里面的eat、sleep方法我们都可以使用
    def __init__(self,weight,num1,num2):
        super(Person,self).__init__(weight,num1)
        self.num2=num2

    #定义eat（）方法集成eat，重写了eat（）方法
    def eat(self):
        print(f'我每天还要吃{self.num2}个汉堡')
        super(Person,self).eat()
    def dance(self):
        print('跳舞')

    def drink(self):
        print('喝酒')
#
# p=Person(142,4,5)
# print(p.game())
# print(p.eat())


class Animal2024():
    def __init__(self,weight,num):
        self.weight=weight
        self.num=num

    def eat(self,man):
        print(f"我是{man}动物，我现在有{self.weight}kg,我每天吃{self.num}顿饭")
    def drink(self):
        print("我喜欢喝酒")

# a=Animal2024(10,2)
# print(a.eat(man="雄性"))
# print(a.drink())
class NewPerison(Animal2024):
    def __init__(self,weight,num,num2):
        super().__init__(weight,num) # 调用父类的初始化方法
        self.num2=num2

    def eat(self,man):
        # 调用父类Animal的eat方法，执行动物的一般吃法
        super().eat(man)
        # 执行人类特有的吃法
        print(f'我是人类，我继承动物，我体重{self.weight},每天还要吃{self.num2}个汉堡')

p=NewPerison(147,3,5)
print(p.eat(man="雌性"))




# class Rectangle():
#     """矩形"""
#
#     def __init__(self, a, b):
#         self.a = a
#         self.b = b
#
#     def area(self):
#         return self.a * self.b
#
#     def perimeter(self):
#         return (self.a + self.b) * 2
#
#
# class Orthogon(Rectangle):
#     """长方形"""
#
#     pass
#
#
# class Square(Rectangle):
#     """正方形"""
#
#     def __init__(self, a):
#         super(Square, self).__init__(a, a)
#
#
# # 一个对象只要“看起来像鸭子，走起路来像鸭子”，那它就可以被看做是鸭子。
# # 多态
#
# # 在java中，不存在多态，因为java在定义方法或者类的时候，就已经确定传参的类型和格式了，python不会在意
# def get_area(s):
#     """获取面积"""
#     return s.area()
#
#
# orthogon = Orthogon(1, 2)
# square = Square(2)
#
# print(get_area(orthogon))
# print(get_area(square))
#
#
# # 封装
# # 1、整合代码(函数)
# def demo():
#     print("步骤1")
#     print("步骤2")
#     print("步骤3")
#
#
# def func1():
#     demo()
#     print("步骤4")
#     print("步骤5")
#
#
# def func2():
#     demo()
#     print("步骤6")
#     print("步骤7")
#
#
# def func3():
#     demo()
#     print("步骤4")
#
#
# # 2、class(整合代码)
#
# class C():
#     def demo(self):
#         print("步骤1")
#         print("步骤2")
#         print("步骤3")
#
#     def func1(self):
#         self.demo()
#         print("步骤4")
#         print("步骤5")
#
#     def func2(self):
#         self.demo()
#         print("步骤6")
#         print("步骤7")
#
#     def func3(self):
#         self.demo()
#         print("步骤4")
#
#
# # 3、class
#
class new_Person():
    # 私有变量
    # 私有属性
    # 私有方法
    def __init__(self, name, age, color):
        self.name = name  # 姓名
        self.age = age  # 年龄
        self.__briefscolor = color  # 内裤颜色

    def __change_briefs(self):
        # 换内裤
        if self.__briefscolor == 'red':
            aa=self.__briefscolor = 'green'
            print(aa)
            return aa

    def change_pants(self):
        # 换裤子
        print(self.__change_briefs())
        print('已经穿好裤子了')
p = new_Person('bob', 25, 'red')
# print(p.name)
# print(p.age)
# print(p.change_pants())
# class Dataframe():
#     def __decry(self):
#         print("解密这个字符串")
#
#     def frame_dict(self):
#         self.__decry()
#         print("把他转化为dict")
#         print("数据处理")
#
#     def frame_list(self):
#         self.__decry()
#         print("把他转化为list")
#         print("数据处理")
#
#
# class H(Dataframe):
#     def kkk(self):
#         self.__decry()
#
#

#
#
# class A():
#     def divison(self, a, b):
#         return a / b
#
#
# class B(A):
#     def divison(self, a, b):
#         a = super(B, self).divison(a, b)
#         a += 1
#         return a
#
#
# class C(A):
#     def divison(self, a, b):
#         if b == 0:
#             return 0
#         a = super(C, self).divison(a, b)
#         return a
